﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ICD2AD14
{
    public partial class IPC_2581Interface : Form
    {
        public IPC_2581Interface()
        {
            InitializeComponent();
        }

        private void btnImoport_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();
            dialog.Filter = "IPC 2581 File (.cvg)|*.cvg|All Files (*.*)|*.*";
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                txtIpc.Text = dialog.FileName;
            }
        }

        private void btnExportToStk_Click(object sender, EventArgs e)
        {
            SaveFileDialog saveFileDialog1 = new SaveFileDialog();
            saveFileDialog1.InitialDirectory = Convert.ToString(Environment.SpecialFolder.MyDocuments);
            saveFileDialog1.Filter = "Stackup Planer(*.stk)|*.stk|All Files (*.*)|*.*";
            saveFileDialog1.FilterIndex = 1;

            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                ProcessFile.IPC2581Flie file = new ProcessFile.IPC2581Flie(txtIpc.Text);
                string content = file.Export4Stk;
                System.IO.File.WriteAllText(saveFileDialog1.FileName, content);
                MessageBox.Show("Success");

            } 
        }
    }
}
